<template>
	<view class="">
		<view class="home" :style="{ paddingTop: systemBarHeight + 'px' }">
			<view class="h-top between align-c">
				<view class="flex align-c" @click="$to(`/pages/home/store?shopId=${shop_id}&provinceId=${detail.shop.province_id}&cityId=${detail.shop.city_id}`)">
					<text v-if="detail && detail.shop && detail.shop.title">{{ detail.shop.title }}</text>
					<text v-else>请选择门店</text>
					<image src="/static/home/drop-down.png" mode="widthFix" class="pull_icon" />
				</view>
				<view class="ht-right" @click="$to('/pages/home/msg')">
					<image src="/static/home/home-msg.png" mode="widthFix"></image>
					<!-- <view class="mess_num">{{ msgnum }}</view> -->
				</view>
			</view>

			<swiper class="swipe-box" :indicator-dots="true" :autoplay="true" :interval="3000" circular :duration="1000" indicator-color="#E6E6E6" indicator-active-color="#F17816">
				<swiper-item v-for="(item, index) in swiperList" :key="index">
					<image :src="$img(item)" mode="aspectFill" class="swipe-img" />
				</swiper-item>
			</swiper>
		</view>
		
		<view class="con-top box">
			<view class="to_title">私教订单</view>
			<view class=" around align-c">
				<view class="con-details"
				v-for="(item,index) in orderList" :key="index"
				@click="$to(`/pages/home/private/private_order?type=${item.type}`)">
					<view class="de_num">{{ item.num }}</view>
					<view class="de-tit">{{ item.tit }}</view>
				</view>
			</view>
		</view>
		
		<view class="tools box">
			<view class="to_title">常用工具</view>
			<view class="tool between align-c">
				<view class="toolcon" v-for="(v,i) in tooldatas" :key="i" @click="$to(`/pages/home${v.path}`)">
					<image :src="`/static/home/${v.icon}.png`" mode="heightFix" />
					<view>{{ v.name }}</view>
				</view>
			</view>
		</view>

		<tabbar :current="1" />
		<view class="place"></view>
	</view>
</template>

<script>
	import tabbar from '@/components/tabbar.vue'
	export default {
		components: {
			tabbar
		},
		data() {
			return {
				systemBarHeight: 0,
				customBar: 0,
				msgnum: 3,
				orderList: [
					{
						tit: '全部',
						num: 0,
						type: '',
					},
					{
						tit: '已支付',
						num: 0,
						type: 2,
					},
					{
						tit: '核销中',
						num: 0,
						type: 3,
					},
					{
						tit: '已完成',
						num: 0,
						type: 4,
					}
				],
				tooldatas: [
					{
						name: "发布课程",
						icon: "publish-lesson",
						path: "/publish/publish"
					}, {
						name: "公开课程",
						icon: "open-Courses",
						path: "/overt/overt_course?type=1"
					}, {
						name: "私教课程",
						icon: "private-Class",
						path: "/overt/overt_course?type=2"
					}, {
						name: "课程订单",
						icon: "courses-order",
						path: "/private/private_order?type="
					}, {
						name: "商品订单",
						icon: "goods-order",
						path: "/commodity_order/commodity_order"
					}, {
						name: "公开订单",
						icon: "open-order",
						path: "/overt/overt_course_order"
					}, {
						name: "会员管理",
						icon: "member-management",
						path: "/member/member_list"
					}, {
						name: "分类管理",
						icon: "classification-management",
						path: "/classify/classification_management"
					}
				],
				swiperList: [],
				shop_id: '',
				page: 1,
				detail: null,
				list: [],
				last_page: 1,
			}
		},
		onLoad() {
			this.getSysteminfo();
		},
		onShow() {
			var shop_id = uni.getStorageSync('shopId');
			this.shop_id = shop_id;
			uni.hideTabBar();
			this.getDetail();
			let token = uni.getStorageSync('token');
			uni.hideTabBar();
			// if(!token) {
			// 	uni.reLaunch({
			// 		url: '/pages/login/login'
			// 	})
			// }else {
			// 	if(!shop_id) {
			// 		uni.navigateTo({
			// 			url: '/pages/home/store'
			// 		})
			// 	}
			// }
		},
		methods: {
			getSysteminfo() { // 获取系统栏高度
				uni.getSystemInfo({
					success: res => {
						this.systemBarHeight = res.statusBarHeight;
					}
				});
			},
			async getDetail() {
				let res = await this.$api.get('staff/index',{
					shop_id: this.shop_id,
				});
				if(res.code == 200) {
					// console.log(res,1111);
					this.detail = res.data;
					uni.setStorageSync('shop',res.data.shop);
					// let total = res.data.course.to;
					// this.last_page = parseInt(total)/parseInt(res.data.course.per_page);
					this.swiperList = JSON.parse(res.data.shop.banner);
					this.watchDetail();
				}
			},
			watchDetail() {
				const { detail } = this;
				if(detail) {
					this.orderList[0].num = detail.all;
					this.orderList[1].num = detail.pay;
					this.orderList[2].num = detail.check;
					this.orderList[3].num = detail.done;
				}
			},
		}
	}
</script>

<style>
	page {
		background: #F7F7F7;
	}
</style>

<style lang="scss" scoped>
	.home {
		padding: 0 27rpx;
		background: linear-gradient(to top, #F7F7F7, #FFF6EF);
		box-sizing: border-box;
		.h-top {
			margin-bottom: 30rpx;
			font-size: 28rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #333333;
			padding: 0 3rpx;
			height: 44px;
			line-height: 44px;
			.pull_icon {
				width: 16rpx;
				height: 9rpx;
				margin-left: 16rpx;
			}

			.ht-right {
				position: relative;

				image {
					width: 40rpx;
					height: 40rpx;
				}

				.mess_num {
					width: 30rpx;
					height: 30rpx;
					line-height: 30rpx;
					background-color: #F51818;
					border-radius: 17rpx;
					position: absolute;
					right: -12rpx;
					top: 0rpx;
					text-align: center;
					color: #FFF;
					font-size: 20rpx;
					align-items: center;
				}
			}
		}

	}
	
	.con-top {
		.con-details {
			text-align: center;
			font-size: 24rpx;
			font-family: PingFang SC Medium;
			color: #999999;
	
			.de_num {
				font-size: 36rpx;
				font-family: PingFang SC Bold;
				font-weight: 500;
				color: #333333;
				font-weight: bold;
				// margin-bottom: 10rpx;
			}
	
		}
	}
	.to_title {
		font-size: 27rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #333333;
		margin-bottom: 10rpx;
	}
	.box {
		border-radius: 12rpx;
		margin: 30rpx 27rpx;
		background-color: #FFF;
		padding: 22rpx 20rpx;
		box-sizing: border-box;
	}
	.tool {
		flex-wrap: wrap;
		.toolcon {
			min-width: 25%;
			text-align: center;
			margin-top: 40rpx;
			font-size: 24rpx;
			color: #666666;
			image {
				display: block;
				width: 44rpx;
				height: 44rpx;
				margin: 0 auto;
				margin-bottom: 10rpx;
			}
		}
	}

	.swipe-box {
		margin: 30rpx 0;
		height: 293rpx;
		border-radius: 20rpx;
		background-color: rgba(0,0,0,0);
		.swipe-img {
			width: 100%;
			height: 293rpx;
			border-radius: 20rpx;
		}
	}
</style>
